package com.sto.stoapp.adapter;

import java.util.HashMap;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sto.stoapp.activity.R;
import com.sto.stoapp.activity.scanner.inquiry.InquiryFieldSql;

/**
 * 显示记录查询   状态   、 单号  、 日期 适配器
 * @author Administrator
 *
 */
public class InquirySelectAdapter extends BaseAdapter {

	private List<HashMap<String, String>> courierList;

	private Context context;
	private InquiryFieldSql fieldSql;

	/**
	 * 构造函数
	 * 
	 * @param context
	 * @param courierList
	 */
	public InquirySelectAdapter(Context context,
			List<HashMap<String, String>> list, InquiryFieldSql fieldSql) {
		this.courierList = list;
		this.context = context;
		this.fieldSql = fieldSql;
	}

	@Override
	public int getCount() {
		return courierList == null ? 0 : courierList.size();
	}

	@Override
	public Object getItem(int arg0) {
		return courierList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		Holder holder;
		if (view == null) {
			holder = new Holder();
			view = LayoutInflater.from(context).inflate(
					R.layout.sto_inquiry_datalist, null);
			holder.status = (TextView) view.findViewById(R.id.inquiryStatus);
			holder.code = (TextView) view.findViewById(R.id.inquirycode);
			holder.date = (TextView) view.findViewById(R.id.inquirydate);
			view.setTag(holder);
		} else {
			holder = (Holder) view.getTag();
		}

		holder.status.setText(courierList.get(position).get(
				fieldSql.INQUIRYSTATUS));
		holder.code.setText(courierList.get(position).get(
				fieldSql.INQUIRYCODE));
		holder.date.setText(courierList.get(position).get(
				fieldSql.INQUIRYDATE));

		return view;
	}

	class Holder {
		TextView status;
		TextView code;
		TextView date;
	}
}
